package cn.swenty.backstage.framework.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author sunyang
 *
 */
public  class RegexUtil {
	
	
	public static List<String> matchList(String str,String reg){
		List<String>  list = new ArrayList<>();
		Pattern pattern = Pattern.compile(reg);
		Matcher matcher = pattern.matcher(str);
		while (matcher.find()) {
			list.add(matcher.group(0));
		}
		return list;
	}
	
	public static String matchFirst(String str,String reg){
		Pattern pattern = Pattern.compile(reg);
		Matcher matcher = pattern.matcher(str);
		if (matcher.find()) {
			return matcher.group();
		}
		return null;
	}
	
	
	public static final String DATE = "\\d{4}-([0-1]|)[0-9]-([0-3]|)[0-9]";
	
	public static final String TIME = "\\d{1,2}:[0-5][0-9]:[0-5][0-9]";
	
	public static final String QQ = "[1-9]\\d{4,10}";
	
}
